﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WF.Model;
using WF.DAL;

namespace WF.BusinessObject
{
    /// <summary>
    /// WF_ApplyType业务对象
    /// </summary>
    public class WF_ApplyType : BOBase<WF_ApplyTypeEntity, DAL.WF_ApplyType>
    {
        #region 构造函数

        public WF_ApplyType() : base() { }
        public WF_ApplyType(WFDBDataContext DataContext) : base(DataContext) { }
        #endregion

        #region 实现基类abstract方法
        /// <summary>
        /// 实现基类的GetById abstract方法
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public override WF_ApplyTypeEntity GetById(string ID)
        {
            var obj = DataContext.WF_ApplyTypes.SingleOrDefault(o => o.ApplyTypeID == ID);
            return new WF_ApplyTypeEntity(obj);
        }
        #endregion

        #region Public 方法
        public List<WF_ApplyTypeEntity> GetAll()
        {
            var target = DataContext.WF_ApplyTypes.ToList();
            List<WF_ApplyTypeEntity> result = new List<WF_ApplyTypeEntity>();
            foreach (var item in target)
            {
                result.Add(new WF_ApplyTypeEntity(item));
            }
            return result;
        }
        #endregion

        #region WF_ApplyType
        /// <summary>
        /// Get All WF_ApplyType
        /// </summary>
        /// <param name="result"></param>
        /// <returns></returns>
        public bool GetAllWF_ApplyTypeEntity(out List<WF_ApplyTypeEntity> result)
        {
            var target = DataContext.WF_ApplyTypes.ToList();
            result = new List<WF_ApplyTypeEntity>();
            foreach (var item in target)
            {
                result.Add(new WF_ApplyTypeEntity(item));
            }

            return true;
        }
        #endregion

        internal WF_ApplyTypeEntity GetByApplyType(string applyTypeName)
        {
            var obj = DataContext.WF_ApplyTypes.SingleOrDefault(o => o.ApplyType == applyTypeName);
            return new WF_ApplyTypeEntity(obj);
        }
    }
}
